package tests.old;
/**
 * contem erro -> está comentado
 * */
/*
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import root.MainManager;
import root.friendship.FriendshipManager;
import root.item.ItemManager;
import root.loan.CurrentDate;
import root.loan.State;
import root.user.User;
import root.user.UserManager;


import exceptions.AbsentAtributException;
import exceptions.BorrowDoesNotExist;
import exceptions.HasAlreadyDoneException;
import exceptions.InvalidAddressCity;
import exceptions.InvalidAddressComplement;
import exceptions.InvalidAddressCountry;
import exceptions.InvalidAddressNeighborhood;
import exceptions.InvalidAddressState;
import exceptions.InvalidAddressStreet;
import exceptions.InvalidAtributException;
import exceptions.InvalidBorrowId;
import exceptions.InvalidDurationException;
import exceptions.InvalidItemCategoryException;
import exceptions.InvalidItemNameException;
import exceptions.InvalidMessage;
import exceptions.InvalidReceiver;
import exceptions.InvalidSubject;
import exceptions.InvalidUserAddress;
import exceptions.InvalidUserException;
import exceptions.InvalidUserName;
import exceptions.InvalidUserUsername;
import exceptions.IsNotOnwerException;
import exceptions.ItemDoesNotExist;
import exceptions.ItemHasAlreadyBorrowedException;
import exceptions.ItemRequestAlreadyExistsException;
import exceptions.LoanHasAlreadyBeenApprovedException;
import exceptions.PermissionDeniedException;
import exceptions.WithoutPermissionRequestLoanException;
import exceptions.YouAreAlreadyFriends;
import exceptions.YouHaveAlreadyRequestedFriendship;
import exceptions.YouHaventReceivedARequest;

public class LoanManagerTest {

	
	CurrentDate loanManager;
	UserManager userManager;
	final String country = "Brasil";
	final String state = "Paraiba";
	final String city = "Joao Pessoa";
	final String neighborhood = "Manaira";
	final String street = "Rua Joaquim";
	final int number = 333;
	final String complement = "";
	String id1;
	String id2;
	User user1;
	User user2;
	final String name = "blabla";
	final String name2 = "bleble";
	final String description = "blabla";
	final String username1 = "testclass1";
	final String username2 = "testclass2";
	final String email = "test@test.com";
	final String address = "oi";
	ItemManager itemManager;
	String tipoTodos = "todos";
	String tipoEmprestador = "emprestador";
	String tipoBeneficiado = "beneficiado";
	
	
	@Before
	public void setUpBefore() throws InvalidAddressCountry, InvalidAddressState, InvalidAddressCity, InvalidAddressNeighborhood, InvalidAddressStreet, InvalidAddressComplement, InvalidUserUsername, InvalidUserName, InvalidUserAddress, InvalidItemNameException, InvalidItemCategoryException, YouHaventReceivedARequest, YouAreAlreadyFriends, InvalidUserException, YouHaveAlreadyRequestedFriendship {
		loanManager = CurrentDate.getInstance();
		itemManager = ItemManager.getItemManager();
		user1 = new User(username1, name, address);
		user2 = new User(username2, name, address);
		id1 = itemManager.createItem(user1, name, description, "Livro");
		id2 = itemManager.createItem(user2, name2, description, "Livro");
		FriendshipManager.getInstance().requestFriendShip(user1, user2);
		FriendshipManager.getInstance().acceptFriendship(user2, user1);
		FriendshipManager.getInstance().validateRelationships();
	}
	
	@After
	public void after() throws Throwable{
		MainManager.zerarSistema();
	}
	
	@Test
	public void testBorrowItem() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		Assert.assertFalse(itemManager.isBorowed(id1));
		String id = loanManager.borrowItem(user2, id1, number);
		Assert.assertFalse(itemManager.isBorowed(id1));
		Assert.assertTrue(loanManager.hasBorrow(id));
	}
	
	@Test(expected = ItemDoesNotExist.class)
	public void testBorrowItem2() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		loanManager.borrowItem(user2, null, number);
	}
	
	@Test(expected = ItemDoesNotExist.class)
	public void testBorrowItem3() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		loanManager.borrowItem(user2, "", number);
	}
	
	@Test(expected = ItemDoesNotExist.class)
	public void testBorrowItem4() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		loanManager.borrowItem(user2, "xpto", number);
	}
	
	@Test(expected=ItemRequestAlreadyExistsException.class)
	public void testBorrowItem5() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		loanManager.borrowItem(user2, id1, number);
		loanManager.borrowItem(user2, id1, number);
	}
	
	@Test(expected=IsNotOnwerException.class)
	public void testBorrowItem6() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user2, id);
	}
	
	@Test(expected=ItemHasAlreadyBorrowedException.class)
	public void testBorrowItem7() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, InvalidUserUsername, InvalidUserName, InvalidUserAddress, WithoutPermissionRequestLoanException, YouHaveAlreadyRequestedFriendship, YouAreAlreadyFriends, InvalidUserException, YouHaventReceivedARequest, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		String id = loanManager.borrowItem(user2, id1, number);
		User user3 = new User("username3", name, address);
		FriendshipManager.getInstance().requestFriendShip(user1, user3);
		FriendshipManager.getInstance().acceptFriendship(user3, user1);
		String id2 = loanManager.borrowItem(user3, id1, number);
		
		loanManager.approveLoan(user1, id);
		loanManager.approveLoan(user1, id2);
	}
	
	@Test(expected=LoanHasAlreadyBeenApprovedException.class)
	public void testBorrowItem8() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.approveLoan(user1, id);
	}
	
	public void testBorrowItem9() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.returnItem(user2, id);
		Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.completeLoan(user1, id);
		Assert.assertFalse(ItemManager.getItemManager().isBorowed(id1));
		
	}
	
	@Test(expected=HasAlreadyDoneException.class)
	public void testBorrowItem10() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.returnItem(user2, id);
		Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.completeLoan(user1, id);
		Assert.assertFalse(ItemManager.getItemManager().isBorowed(id1));
		loanManager.completeLoan(user1, id);
		
	}
	
	@Test(expected=HasAlreadyDoneException.class)
	public void testBorrowItem11() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.returnItem(user2, id);
	}

	
	@Test(expected=HasAlreadyDoneException.class)
	public void testBorrowItem12() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.returnItem(user2, id);Assert.assertTrue(ItemManager.getItemManager().isBorowed(id1));
		loanManager.completeLoan(user1, id);
		loanManager.returnItem(user2, id);
		
	}

	@Test(expected=PermissionDeniedException.class)
	public void testBorrowItem13() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		//loanManager.approveLoan(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.completeLoan(user1, id);
		
	}
	
	@Test
	public void testBorrowItem14() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.requestDevolution(user1, id);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Cancelado", loanManager.getEmprestimos(user1, "todos"));
	}
	
	@Test
	public void testBorrowItem15() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.requestDevolution(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.completeLoan(user1, id);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Cancelado", loanManager.getEmprestimos(user1, "todos"));
	}
	
	@Test
	public void testBorrowItem16() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.requestDevolution(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.completeLoan(user1, id);
		Assert.assertFalse(ItemManager.getItemManager().isBorowed(id1));
	}
	
	@Test
	public void testBorrowItem17() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.addDays(number+1);
		loanManager.requestDevolution(user1, id);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Andamento", loanManager.getEmprestimos(user1, "todos"));
		loanManager.returnItem(user2, id);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Andamento", loanManager.getEmprestimos(user1, "todos"));
		loanManager.completeLoan(user1, id);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Completado", loanManager.getEmprestimos(user1, "todos"));
	}
	
	@Test(expected=PermissionDeniedException.class)
	public void testBorrowItem18() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.completeLoan(user1, id);
	}
	
	@Test(expected=PermissionDeniedException.class)
	public void testBorrowItem19() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException, HasAlreadyDoneException {
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.requestDevolution(user1, id);
		loanManager.completeLoan(user1, id);
	}

	
	@Test
	public void testHasBorrowString() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver {
		Assert.assertFalse(loanManager.hasBorrow("xpto"));
		String id = loanManager.borrowItem(user2, id1, number);
		Assert.assertTrue(loanManager.hasBorrow(id));
	}

	@Test
	public void testApproveLoan() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		Assert.assertFalse(itemManager.isBorowed(id1));
		String id = loanManager.borrowItem(user2, id1, number);
		Assert.assertFalse(itemManager.isBorowed(id1));
		loanManager.approveLoan(user1, id);
		Assert.assertTrue(itemManager.isBorowed(id1));
	}
	
	@Test
	public void testCompleteDevolution() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, PermissionDeniedException, HasAlreadyDoneException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver{
		Assert.assertFalse(itemManager.isBorowed(id1));
		String id = loanManager.borrowItem(user2, id1, number);
		Assert.assertFalse(itemManager.isBorowed(id1));
		loanManager.approveLoan(user1, id);
		Assert.assertTrue(itemManager.isBorowed(id1));
		loanManager.returnItem(user2, id);
		Assert.assertTrue(itemManager.isBorowed(id1));
		loanManager.completeLoan(user1, id);
		Assert.assertFalse(itemManager.isBorowed(id1));
	}
	
	@Test(expected=HasAlreadyDoneException.class)
	public void testCompleteDevoluion2() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, PermissionDeniedException, HasAlreadyDoneException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver{
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.completeLoan(user1, id);
		loanManager.completeLoan(user1, id);
	}
	

	@Test(expected=HasAlreadyDoneException.class)
	public void testCompleteDevoluion3() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, PermissionDeniedException, HasAlreadyDoneException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver{
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.returnItem(user2, id);
	}
	
	@Test(expected=PermissionDeniedException.class)
	public void testCompleteDevoluion4() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, PermissionDeniedException, HasAlreadyDoneException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver{
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.returnItem(user1, id);
	}
	
	@Test(expected=PermissionDeniedException.class)
	public void testCompleteDevoluion5() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, WithoutPermissionRequestLoanException, InvalidDurationException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, PermissionDeniedException, HasAlreadyDoneException, InvalidBorrowId, InvalidAtributException, AbsentAtributException, InvalidMessage, InvalidSubject, InvalidReceiver{
		String id = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id);
		loanManager.returnItem(user2, id);
		loanManager.completeLoan(user2, id);
	}


	@Test(expected=BorrowDoesNotExist.class)
	public void testApproveLoan2() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, InvalidBorrowId, PermissionDeniedException {
		loanManager.approveLoan(user2, null);
	}
	
	@Test(expected=BorrowDoesNotExist.class)
	public void testApproveLoan3() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, InvalidBorrowId, PermissionDeniedException {
		loanManager.approveLoan(user2, "");
	}
	
	@Test(expected=InvalidBorrowId.class)
	public void testApproveLoan4() throws ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, InvalidBorrowId, PermissionDeniedException {
		loanManager.approveLoan(user2, "xpto");
	}
	
	@Test
	public void testGetEmprestimos() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist {
		Assert.assertEquals("Não há empréstimos deste tipo",loanManager.getEmprestimos(user1,tipoTodos));
		Assert.assertEquals("Não há empréstimos deste tipo",loanManager.getEmprestimos(user1,tipoEmprestador));
		Assert.assertEquals("Não há empréstimos deste tipo",loanManager.getEmprestimos(user1,tipoBeneficiado));
	}
	
	@Test
	public void testGetEmprestimos2() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		String id = loanManager.borrowItem(user1, id2, number);
		loanManager.approveLoan(user2, id);
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user1,tipoTodos));
		Assert.assertEquals("Não há empréstimos deste tipo",loanManager.getEmprestimos(user1,tipoEmprestador));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user1,tipoBeneficiado));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user2,tipoTodos));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user2,tipoEmprestador));
		Assert.assertEquals("Não há empréstimos deste tipo",loanManager.getEmprestimos(user2,tipoBeneficiado));
	}
	
	@Test
	public void testGetEmprestimos3() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException, ItemHasAlreadyBorrowedException, WithoutPermissionRequestLoanException, InvalidDurationException, InvalidBorrowId, InvalidMessage, InvalidSubject, InvalidReceiver, PermissionDeniedException {
		String id = loanManager.borrowItem(user1, id2, number);
		loanManager.approveLoan(user2, id);
		String id3 = loanManager.borrowItem(user2, id1, number);
		loanManager.approveLoan(user1, id3);
		Assert.assertEquals(username1 + "-" + username2 + ":" + name +":Andamento"+ "; " + username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user1,tipoTodos));
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Andamento",loanManager.getEmprestimos(user1,tipoEmprestador));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user1,tipoBeneficiado));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento" + "; " + username1 + "-" + username2 + ":" + name+":Andamento",loanManager.getEmprestimos(user2,tipoTodos));
		Assert.assertEquals(username2 + "-" + username1 + ":" + name2+":Andamento",loanManager.getEmprestimos(user2,tipoEmprestador));
		Assert.assertEquals(username1 + "-" + username2 + ":" + name+":Andamento",loanManager.getEmprestimos(user2,tipoBeneficiado));
		
	}
	
	@Test(expected = AbsentAtributException.class)
	public void testGetEmprestimos4() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException {
		loanManager.getEmprestimos(user1, "xpto");
	}
	
	@Test(expected = InvalidAtributException.class)
	public void testGetEmprestimos5() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException {
		loanManager.getEmprestimos(user1, null);
	}
	
	@Test(expected = InvalidAtributException.class)
	public void testGetEmprestimos6() throws InvalidAtributException, AbsentAtributException, ItemDoesNotExist, ItemRequestAlreadyExistsException, IsNotOnwerException, BorrowDoesNotExist, LoanHasAlreadyBeenApprovedException {
		loanManager.getEmprestimos(user1, "");
	}

}*/
